const mongoose = require('./db')
const Schema = mongoose.Schema
// 个人信息表
let codeidSchema = new Schema({
    name: String,
    codeid: Number,
    email: String,
    phone: Number,
    img1: String,
    img2: String,
})
let codeidModel = mongoose.model('codeid', codeidSchema, 'codeid')
// 公司信息表
let enterpriseCertificationSchema = mongoose.Schema({
    name: String,
    code: Number,
    legalPersonName: String,
    legalPersonCode: Number,
    email: String,
    phone: Number,
    img: String
})
let enterpriseCertificationModel = mongoose.model('enterpriseCertification', enterpriseCertificationSchema, 'enterpriseCertification')
let LoginSchema = new Schema({
    username: String,
    password: String,
    phone: Number,
    role: String,
    CodeId: {
        type: mongoose.Types.ObjectId,
        ref: "codeid",
        default: null
    },
    enterpriseId: {
        type: mongoose.Types.ObjectId,
        ref: "enterpriseCertification",
        default: null
    },
    Juddeposit:{
        type:Number,
        default:0
    },
    Ordposit:{
        type:Number,
        default:0
    }
})

let LoginModel = mongoose.model('login', LoginSchema, 'login')

module.exports = {
    LoginModel,
    codeidModel,
    enterpriseCertificationModel
}